package com.ittx.dzt.meituan.service;

import com.ittx.dzt.edi.dto.PlatformApiParamDTO;
import com.ittx.dzt.meituan.constant.MeituanApiConstant;
import com.ittx.dzt.meituan.handler.AbstractBaseMeituanApiHandler;
import com.ittx.dzt.sys.response.Result;
import open.dto.StoreOnSaleSkuDto;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 商品下架
 * <p>
 * cy.sku.delisting
 * /api/v1/gw/goods/batchUpdateStatus (批量修改商品上下架)  https://tscc.meituan.com/home/doc/bulkPurchasing/545
 * </p>
 *
 * @author gywang
 * @since 2024-08-01
 */
@Service
public class MeituanSkuDeListingService extends AbstractBaseMeituanApiHandler<StoreOnSaleSkuDto> {
    @Override
    public String getMeituanMethod() {
        return MeituanApiConstant.GOODS_BATCHUPDATESTATUS;
    }

    @Override
    public String getLocalApiMethod() {
        return open.constant.PlatformApiConstant.InboundInterface.SKU_DELISTING;
    }

    @Override
    public Result doProcess(PlatformApiParamDTO platformApiParamDTO, StoreOnSaleSkuDto storeOnSaleSkuDto) {
        Map<String, String> params = new HashMap<>();
        // 商品id
        params.put("goods_id_list", storeOnSaleSkuDto.getPlatformSpuId());
        //商品上下架状态： 0-上架 1-下架
        params.put("sale_status", "1");
        params.put("poi_id", getPoIId(platformApiParamDTO));
        Result<?> result = this.executeMeituanApi(platformApiParamDTO.getStoreConfig(), params, platformApiParamDTO.getRequestId());
        return result;
    }


    @Override
    public String getHttpMethod() {
        return MeituanApiConstant.ApiHttpMethod.POST;
    }
}
